
$(function () {
    /*宝和北初始化代码*/
    $('[data-toggle="tooltip"]').tooltip()
    var items = $('.carousel-inner .item');
    $(window).on('resize', function () {
        /*屏幕的宽度*/
        var width = $(window).width();
        if (width >= 768) {
            items.each(function (index, value) {
                var item = $(this);
                var imgSrc = item.data('largeImage');
                item.html($('<a href="javascript:;" class="pcImg"></a>').css('backgroundImage',"url("+imgSrc+")"))
            })
        } else {
            items.each(function (index, value) {
                var item = $(this);
                var imgSrc = item.data('smallImage');
                item.html('<a href="javascript:;" class="mobileImg"><img src="'+imgSrc+'"></a>')
            })
        }
    }).trigger('resize')
    var startX,endX,distanceX;
    var carousel_inner = $('.carousel-inner')[0];
    /*获取轮播图盒子*/
    var carousel = $('.carousel');
    carousel_inner.addEventListener('touchstart', function (e) {
        startX = e.targetTouches[0].clientX;
    })
    carousel_inner.addEventListener('touchend', function (e) {
        endX = e.changedTouches[0].clientX;
        distanceX = endX - startX;
        if (distanceX > 0) {
            carousel.carousel('prev')
        } else {
            carousel.carousel('next')
        }
    })
    carousel.carousel({
        interval: 2000
    })
    var ul = $('.wjs_product .nav-tabs');
    var lis = ul.find('li');
    var totalWidth = 0;
    lis.each(function (index,value) {
        totalWidth = totalWidth + $(this).innerWidth();
    })
    ul.width(totalWidth);
    var myScroll = new IScroll('.tabs_parent',{
        /*设置水平滑动，不允许垂直滑动*/
        scrollX: true, scrollY: false
    });
})